//
//  SRSportShareContentForMonthView.m
//  SportRing
//
//  Created by elwin on 10/30/14.
//  Copyright (c) 2014 HotOne. All rights reserved.
//

#import "SRSportShareContentForMonthView.h"
#import "SREvaluateView.h"
#import "HKCircleChartView.h"

#define TEXT_COLOR [UIColor red:231 green:99 blue:40 alpha:1.0]
#define TEXT_SIZE 16


@implementation SRSportShareContentForMonthViewModel


@end

@interface SRSportShareContentForMonthView()<HKCircleChartViewDataSoucre>

@property (nonatomic, weak)IBOutlet UIView *distanceChartViewContainerView;
@property (nonatomic, weak)IBOutlet UIView *kalorieChartViewContainerView;
@property (nonatomic, weak)IBOutlet UIView *stepsChartViewContainerView;
@property (nonatomic, weak)IBOutlet UIImageView *starContainerView;
@property (nonatomic, weak)IBOutlet UILabel *distanceTextLabel;
@property (nonatomic, weak)IBOutlet UILabel *distanceContentLabel;
@property (nonatomic, weak)IBOutlet UILabel *kalorieTextLabel;
@property (nonatomic, weak)IBOutlet UILabel *kalorieContentLabel;
@property (nonatomic, weak)IBOutlet UILabel *stepsTextLabel;
@property (nonatomic, weak)IBOutlet UILabel *stepsContentLabel;
@property (nonatomic, weak)IBOutlet UILabel *averageContentLabel;

@end

@implementation SRSportShareContentForMonthView

- (void)awakeFromNib
{
    [super awakeFromNib];
    
}

- (void)setSRSportShareContentForMonthViewData:(SRSportShareContentForMonthViewModel*)model
{
    SREvaluateView *starView1 = [[SREvaluateView alloc]  initWithSelectedImage:[UIImage imageNamed:@"star"] notSelectedImage:[UIImage imageNamed:@"star_1"] notSelectedCount:5-model.star selectedCount:model.star];
    [self.starContainerView addSubview:starView1];
    
    [self setDistanceChartViewWithProcess:model.distanceChartViewProgress];
    [self setStepsChartViewWithProcess:model.stepsChartViewProgress];
    [self setKaloriChartViewWithProcess:model.kalorieChartViewProgess];
    
    self.distanceContentLabel.text = [NSString stringWithFormat:@"%.1f",model.distance];
    self.kalorieContentLabel.text = [NSString stringWithFormat:@"%d",(int)model.kalorie];
    self.stepsContentLabel.text = [NSString stringWithFormat:@"%ld",model.steps];
    
    NSAttributedString *averageContent = [SRHelper attString:[NSString stringWithFormat:@"平均每天走%d步，约%.1f公里，燃烧%d卡路里。",model.averageSteps,model.averageDistance / 5000000, (int)model.averageKalorie]
                                         fromString:[[NSMutableArray alloc] initWithObjects:@"平均每天走",@"，约",@"燃烧", nil]
                                           toString:[[NSMutableArray alloc] initWithObjects:@"步",@"公里",@"卡路里。", nil]
                                           fontSize:[[NSMutableArray alloc] initWithObjects:[UIFont systemFontOfSize:TEXT_SIZE],[UIFont systemFontOfSize:TEXT_SIZE],[UIFont systemFontOfSize:TEXT_SIZE], nil]
                                              color:[[NSMutableArray alloc] initWithObjects:TEXT_COLOR,TEXT_COLOR,TEXT_COLOR, nil]];
    self.averageContentLabel.attributedText = averageContent;
}

- (void)setDistanceChartViewWithProcess:(float)process
{
    
    HKCircleChartView *chartView = [[HKCircleChartView alloc] initWithFrame:CGRectMake(0, 0, self.distanceChartViewContainerView.frame.size.width, self.distanceChartViewContainerView.frame.size.height)];
    
    chartView.dataSoucre = self;
    
    [self.distanceChartViewContainerView addSubview:chartView];
    
    [chartView makeCircleChartProcess:process animation:YES];
    
}

- (void)setStepsChartViewWithProcess:(float)process
{
    
    HKCircleChartView *chartView = [[HKCircleChartView alloc] initWithFrame:CGRectMake(0, 0, self.stepsChartViewContainerView.frame.size.width, self.stepsChartViewContainerView.frame.size.height)];
    
    chartView.dataSoucre = self;
    
    [self.stepsChartViewContainerView addSubview:chartView];
    
    [chartView makeCircleChartProcess:process animation:YES];
    
}

- (void)setKaloriChartViewWithProcess:(float)process
{
    
    HKCircleChartView *chartView = [[HKCircleChartView alloc] initWithFrame:CGRectMake(0, 0, self.kalorieChartViewContainerView.frame.size.width, self.kalorieChartViewContainerView.frame.size.height)];
    
    chartView.dataSoucre = self;
    
    [self.kalorieChartViewContainerView addSubview:chartView];
    
    [chartView makeCircleChartProcess:process animation:YES];
}

#pragma mark - HKCircleChartViewDataSoucre

- (HKCircleChartSettingModel *)circleChartViewSettingModel{
    
    HKCircleChartSettingModel *model = [[HKCircleChartSettingModel alloc] init];
    
    model.clockwise = YES;
    
    model.ringWidth = 5;
    
    model.animationDuration = 0.5;
    
    model.circleColer = [UIColor colorWithRed:127.0/255.0 green:208.0/255.0 blue:28.0/255.0 alpha:1.0f];
    
    model.circleBGColer = [UIColor clearColor];
    
    return model;
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
